package ac.zlf.springmybatis.init;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;

@SuppressWarnings("deprecation")
public class HibernateUtil {
	private static Session session;
	static{
		Configuration config = new AnnotationConfiguration();
		config.configure();
		SessionFactory sessionFactory = config.buildSessionFactory();

		session = sessionFactory.getCurrentSession();
		
		sessionFactory = new Configuration().configure("hibernate.cfg.xml")  
                .buildSessionFactory();
	}
	public static Session getSession() {
		return session;
	}
	public static void setSession(Session session) {
		HibernateUtil.session = session;
	}
	
	
}
